package com.amit.servlet;

import java.io.IOException;


import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

@WebServlet(name="logout",urlPatterns="/logout.jlc",loadOnStartup=1)
public class LogoutServlet  extends HttpServlet{
	
	@Override
	protected void service(HttpServletRequest req, HttpServletResponse res)
			throws ServletException, IOException {
		
		
		try
		{
			HttpSession session=req.getSession();
			session.invalidate();
			
			RequestDispatcher rd=req.getRequestDispatcher("/logout.html");
			rd.forward(req, res);
		}
		
		catch (Exception e) {
			e.printStackTrace();
			
		}
		
	}

}
